import QtQuick 2.0

Rectangle {
    signal clicked;

    property alias image: imageShow;
    property alias text: lable;

    id: root;
    width: 300;
    height: 240;

    color: "#333";
    border.color: Qt.lighter(color, 1.2);

    Image {
        id: imageShow;
        anchors.left: parent.left;
        anchors.top: parent.top;
        anchors.right: parent.right;
        anchors.bottom: lable.top;

        fillMode: Image.PreserveAspectCrop;

//        onStatusChanged: {
//            if (imageShow.status == Image.Error) {
//                imageShow.source = imageShow.source;
//            }
//        }
    }

    Text {
        id: lable;
        height: 40;
        anchors.left: parent.left;
        anchors.right: parent.right;
        anchors.bottom: parent.bottom;

        horizontalAlignment: Text.AlignHCenter;
        verticalAlignment: Text.AlignVCenter;
        color: "white";
        font.pointSize: 16;
    }

    MouseArea {
        anchors.fill: parent;
        onClicked: {
            root.clicked();
        }
    }
}
